<?php

namespace plugin\admin\app\model;

use app\payment\PayFactory;
use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property integer $user_id 用户ID
 * @property integer $source 资产变化类型
 * @property string $type 资产类型
 * @property string $before 变化前余额
 * @property string $amount 变化余额
 * @property string $remark 变化备注
 * @property string $order_no 订单编号
 * @property string $created_time 创建时间
 * @property integer $reward_type 奖励类型,1直推,2间推
 */
class UserPropertyLog extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_user_property_logs';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;


    const FREEZE_INTEGRAL_GIVE = 100;

    const FREEZE_INTEGRAL_RELEASE = 101;

    const INTEGRAL_TO_REGISTER_INTEGRAL = 300;  //积分转注册积分

    const INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE = 301;  //冻结积分解冻

    const INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE_TEAM = 302;

    const INTEGRAL_RECOMMEND_REWARD = 303;

    const INTEGRAL_INDIRECT_RECOMMEND_REWARD = 304;

    const INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE_BORROW = 305;

    const INTEGRAL_DISTRICT_PARTNER_REWARD = 306;

    const INTEGRAL_CITY_PARTNER_REWARD = 307;

    const INTEGRAL_FROM_OTHER_PERSON = 308;

    const INTEGRAL_TO_OTHER_PERSON = 309;

    const RECHARGE = 400;

    const SYSTEM_REDUCE = 401;

    const RECHARGE_INTEGRAL_GIVE = 500; //充值积分转赠

    const RECHARGE_INTEGRAL_RECEIVE = 501;  //充值积分接收

    const RECHARGE_INTEGRAL_ORDER_PAY = 502;    //充值积分支付订单

    const RECHARGE_INTEGRAL_ORDER_REFUND = 503;  //订单退款

    const RECHARGE_INTEGRAL_FROM_OTHER_PERSON = 504;

    const RECHARGE_INTEGRAL_TO_OTHER_PERSON = 505;

    const REGISTER_INTEGRAL_GIVE = 600; //注册积分转赠

    const REGISTER_INTEGRAL_RECEIVE = 601;  //注册积分接收

    const REGISTER_INTEGRAL_FROM_INTEGRAL = 602;    //积分转注册积分

    const REGISTER_INTEGRAL_ORDER_PAY = 603;    //注册积分支付订单

    const REGISTER_INTEGRAL_ORDER_REFUND = 604; //订单退款

    const REGISTER_INTEGRAL_FROM_OTHER_PERSON = 605;

    const REGISTER_INTEGRAL_TO_OTHER_PERSON = 606;

    const UNFREEZE_INTEGRAL_RELEASE = 700;

    const UNFREEZE_INTEGRAL_RELEASE_TEAM = 701;

    const UNFREEZE_INTEGRAL_RELEASE_BORROW = 702;

    const BORROW_INTEGRAL_ADD = 800;

    const BORROW_INTEGRAL_REDUCE = 801;

    const BORROW_INTEGRAL_ADD_TEAM = 802;

    const COIN_GET = 3;

    const EXCHANGE_TO_SD = 4;

    const FROM_SB = 5;

    const FROM_AD = 6;

    const IDENTIFY = 7;

    const PAY_ORDER = 8;

    const ORDER_PAY_BACK = 9;

    const FINISH_PROFILE = 10;

    const REBATE_INTEGRAL_INCOME = 11;

    const REBATE_CONTRIBUTION_INCOME = 12;

    const REBATE_INTEGRAL_TO_UPLINE = 13;

    const SYSTEM_CLEAR_CONTRIBUTION = 14;

    const CONTRIBUTION_TO_BALANCE = 15;

    const EXTRA_REBATE = 16;

    const REBATE_CONTRIBUTION_TO_UPLINE = 17;

    const WITHDRAW = 18;

    const REWARD_INTEGRAL_REDUCE = 900;

    const REWARD_INTEGRAL_DISTRICT_RANGE_REWARD = 901;

    const REWARD_INTEGRAL_CITY_RANGE_REWARD = 902;

    const SOURCE_TEXT = [
        self::RECHARGE => '后台充值',
        self::SYSTEM_REDUCE => '后台扣除',
        self::FREEZE_INTEGRAL_GIVE => '充值积分赠送',
        self::FREEZE_INTEGRAL_RELEASE => '解冻释放',
        self::COIN_GET => '日常收益',
        self::EXCHANGE_TO_SD => '兑换成视点',
        self::FROM_SB => '兑换视点',
        self::FROM_AD => '观看激励广告获得',
        self::IDENTIFY => '实名赠送',
        self::PAY_ORDER => '支付订单',
        self::ORDER_PAY_BACK => '订单退款',
        self::FINISH_PROFILE => '完善资料',
        self::INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE_TEAM => '推广VIP团队奖励释放',
        self::INTEGRAL_TO_REGISTER_INTEGRAL => '积分转注册积分',
        self::INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE => '分享加速释放',
        self::INTEGRAL_FROM_FREEZE_INTEGRAL_RELEASE_BORROW => '累计积分解冻释放',
        self::INTEGRAL_RECOMMEND_REWARD => '网体见点',
        self::INTEGRAL_INDIRECT_RECOMMEND_REWARD => '平级奖',
        self::INTEGRAL_DISTRICT_PARTNER_REWARD => '物流补贴',
        self::INTEGRAL_CITY_PARTNER_REWARD => '物流补贴',
        self::INTEGRAL_FROM_OTHER_PERSON => '子账号积分归集',
        self::INTEGRAL_TO_OTHER_PERSON => '子账号积分归集',
        self::REBATE_INTEGRAL_INCOME => '购买报单产品赠送积分',
        self::REBATE_CONTRIBUTION_INCOME => '购买报单产品赠送贡献值',
        self::REBATE_INTEGRAL_TO_UPLINE => '下级返点积分',
        self::SYSTEM_CLEAR_CONTRIBUTION => '贡献值系统自动清零',
        self::CONTRIBUTION_TO_BALANCE => '贡献值转余额',
        self::EXTRA_REBATE => '直推订单达标额外奖励',
        self::REBATE_CONTRIBUTION_TO_UPLINE => '下级购买报单产品贡献值返点',
        self::WITHDRAW => '提现',
        self::RECHARGE_INTEGRAL_GIVE => '充值积分转赠',
        self::RECHARGE_INTEGRAL_RECEIVE => '充值积分接收',
        self::RECHARGE_INTEGRAL_ORDER_PAY => '丰安动力充值卡',
        self::RECHARGE_INTEGRAL_ORDER_REFUND => '充值积分订单退款',
        self::RECHARGE_INTEGRAL_FROM_OTHER_PERSON => '子账号充值积分归集',
        self::RECHARGE_INTEGRAL_TO_OTHER_PERSON => '子账号充值积分归集',
        self::REGISTER_INTEGRAL_GIVE => '注册积分转赠',
        self::REGISTER_INTEGRAL_RECEIVE => '注册积分接收',
        self::REGISTER_INTEGRAL_ORDER_PAY => '丰安动力充值卡',
        self::REGISTER_INTEGRAL_ORDER_REFUND => '注册积分订单退款',
        self::REGISTER_INTEGRAL_FROM_OTHER_PERSON => '子账号注册积分归集',
        self::REGISTER_INTEGRAL_TO_OTHER_PERSON => '子账号注册积分归集',
        self::REGISTER_INTEGRAL_FROM_INTEGRAL => '积分转注册积分',
        self::UNFREEZE_INTEGRAL_RELEASE => '释放至积分(分享加速)',
        self::UNFREEZE_INTEGRAL_RELEASE_TEAM => '释放至积分(团队加速)',
        self::UNFREEZE_INTEGRAL_RELEASE_BORROW => '累计积分解冻释放',
        self::BORROW_INTEGRAL_ADD => '未释放累计',
        self::BORROW_INTEGRAL_ADD_TEAM => '未释放累计',
        self::BORROW_INTEGRAL_REDUCE => '释放扣除',
        self::REWARD_INTEGRAL_REDUCE => '后台扣除',
        self::REWARD_INTEGRAL_DISTRICT_RANGE_REWARD => '区县合伙人见点奖',
        self::REWARD_INTEGRAL_CITY_RANGE_REWARD => '城市合伙人见点奖',
    ];

    const TYPE_TEXT = [
        PayFactory::INTEGRAL => '积分',
        PayFactory::FREEZE_INTEGRAL => '冻结积分',
        PayFactory::UNFREEZE_INTEGRAL => '已解冻积分',
        PayFactory::REGISTER_INTEGRAL => '注册积分',
        PayFactory::RECHARGE_INTEGRAL => '充值积分',
        PayFactory::BORROW_INTEGRAL => '欠释放积分',
        PayFactory::REWARD_INTEGRAL => '流通积分'
    ];


    public static function getPayWayText($payWay)
    {
        switch ($payWay) {
            case PayFactory::BALANCE:
                return '余额';
            case PayFactory::WECHAT:
                return '微信支付';
            case PayFactory::ALIPAY:
                return '支付宝支付';
        }
    }

    public static function getTypeText($payWay)
    {
        return self::TYPE_TEXT[$payWay];
    }

    public static function getSourceText($source)
    {
        return self::SOURCE_TEXT[$source] ?? '其它';
    }
}
